package st

import (
	"database/sql"
	"github.com/google/wire"
)

func NewDB() *sql.DB {
	return &sql.DB{}
}

type UserDao struct {
	db *sql.DB
}

func NewUserDao(db *sql.DB) *UserDao {
	return &UserDao{db: db}
}

type UserService struct {
	userDao *UserDao
}

func NewUserService(userDao *UserDao) *UserService {
	return &UserService{userDao: userDao}
}

type UserController struct {
	userService *UserService
}

func NewUserController(userService *UserService) *UserController {
	return &UserController{userService: userService}
}

// 对controller依赖进行分组
var UserProviderSet = wire.NewSet(NewDB, NewUserDao, NewUserService)

// wire.Struct(new(UserController), "userService")  对UserController的userService字段注入
// wire.Struct(new(UserController), "*") 对UserController的所有字段注入

var CtrlProder = wire.NewSet(wire.Struct(new(UserController), "userService"))
